package com.service;

import com.model.Fictitious;

import java.util.List;
import java.util.Random;

public class Commonmethod {



    public static  int getuserid(){
        Fictitious fuser = null;
        try {
            Fictitious f =  Fictitious.dao.findFirst("select id from tp_users_20171014 order by id asc limit 1");
            Fictitious fmax =  Fictitious.dao.findFirst("select id from tp_users_20171014 order by id desc limit 1");
            Integer max = fmax.getInt("id");
            Integer min = f.getInt("id");
            Random rand = new Random();
            int randNumber =rand.nextInt(max - min + 1) + min;
            fuser = Fictitious.dao.findById(randNumber);
            if(fuser!=null){
                return  fuser.getInt("user_id");
            }
          return 0;
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }

}
